import { Model } from '@vuex-orm/core';
import {getToken} from "../utils/auth";

export default class MinishopSku extends Model {
    // This is the name used as module name of the Vuex Store.
    static entity = 'minishop_sku';

    // List of all fields (schema) of the post model. `this.attr` is used
    // for the generic field type. The argument is the default value.
    static fields() {
        return {
            id: this.attr(null),
            product_id: this.number(''),
            out_product_id: this.string(''),
            sku_id: this.number(''),
            out_sku_id: this.string(''),
            sku_name: this.string(''),
            thumb_img: this.string(''),
            sale_price: this.string(''),
            market_price: this.string(''),
            stock_num: this.string(''),
            barcode: this.string(''),
            sku_code: this.string(''),
            status: this.number(''),
            sku_attrs: this.attr(''),         //数据库保存的是数字数组，前端ORM类型attr自动转成了字符串数组
            creator_id: this.attr(''),
            created_at: this.attr(''),
            updated_at: this.attr(''),
            deleted_at: this.attr(0)
        };
    }

    static syncData(params) {
        let result = this.api().post(`/minishopSkus/syncData`,params,{persistBy: 'create' });
        console.log(result);
      /*  if(result.response.data.code == 10000){
            console.log(result.response.data);
        }else{
            console.log(result.response.data.message);
        } */
        return result;
    }

}
